#include <cstdlib>
#include <iostream>
#include <ostream>
#include <vector>

#include "myallocator.h"

class Foo {
public:
    Foo(int a, int b, int c) : a(a), b(b), c(c) {
    }

    Foo(const Foo& other) : a(other.a), b(other.b), c(other.c) {
        std::cout << "const Foo&" << std::endl;
    }

    Foo(Foo&& other) : a(other.a), b(other.b), c(other.c) {
        std::cout << "Foo&&" << std::endl;
    }

    friend std::ostream& operator<<(std::ostream& os, const Foo& val);

private:
    int a;
    int b;
    int c;
};

std::ostream& operator<<(std::ostream& os, const Foo& val) {
    os << "{" << val.a << "," << val.b << "," << val.c << "}";
    return os;
}
int main() {
    std::vector<int, myallocator<int>> v;

    for (int i = 0; i < 10; ++i) {
        v.push_back(rand() % 1000);
    }

    for (auto i : v) {
        std::cout << i << " ";
    }
    std::cout << std::endl;

    std::cout << "==========================" << std::endl;
    std::vector<Foo, myallocator<Foo>> v2;
    v2.reserve(10);
    for (int i = 0; i < 10; ++i) {
        v2.push_back({i, i * i, i * i * i});
    }

    for (auto i : v2) {
        std::cout << i << " ";
    }
    return 0;
}
